

<html>
  <head>
    <nav:resources/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main" />
    <title>Create Topic</title>
    <style>
      #preview {
        width: 270px;
        height: 129px;
      }
    </style>
    <!--[if IE]>
    <style>
      #preview {
        filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);
      }
    </style>
    <![endif]-->
  </head>
  <body><g:render template="/banner"/>
    <div class="nav">
      <span class="menuButton"><a class="home" href="${resource(dir:'')}">Home</a></span>
      <span class="menuButton"><g:link class="list" action="list">Topic List</g:link></span>
    </div>
    <div class="body">
      <h1>发起一个新的讨论话题</h1>
      <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
      </g:if>
      <g:hasErrors bean="${topicInstance}">
        <div class="errors">
          <g:renderErrors bean="${topicInstance}" as="list" />
        </div>
      </g:hasErrors>
      <g:uploadForm action="save" method="post"  enctype="multipart/form-data">
        <div class="dialog">
          <table>
            <tbody>

              <tr class="prop">
                <td valign="top" class="name">
                  <label for="name">话题名称:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean:topicInstance,field:'name','errors')}">
                  <input type="text" size="50	" maxlength="100" id="name" name="name" value="${fieldValue(bean:topicInstance,field:'name')}"/>
                </td>
              </tr>

              <tr class="prop">
                <td valign="top" class="name">
                  <label for="topicCategory">所属类别:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean:topicInstance,field:'topicCategory','errors')}">
            <g:select optionKey="id" from="${TopicCategory.list()}" name="topicCategory.id" value="${topicInstance?.topicCategory?.id}" noselection="['','选择类别']" ></g:select>
            </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="description">话题背景:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean:topicInstance,field:'description','errors')}">
            <g:textArea id="description" name="description" rows="3" cols="50">${fieldValue(bean:topicInstance,field:'description')}</g:textArea>
            </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="image">Image:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean:topicInstance,field:'image','errors')}">
                <script type="text/javascript">
                  function preview(image, preImg)
                  {
                    if ("Microsoft Internet Explorer" == navigator.appName) {
                      preImg.style.visibility = "visible";
                      document.getElementById("preview").filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = image.value;
                    } else if ("Netscape" == navigator.appName){
                      preImg.style.visibility = "visible";
                      preImg.src = image.files[0].getAsDataURL();
                    } else {
                      //alert("Not Support!");
                    }
                  }
                </script>
                <input type="file" id="image" name="image" onchange="javascript:preview(this, document.getElementById('img'));"/>
                <div id="preview" style="overflow:hidden;width:200px;height:100px">
                <img id="img" STYLE="visibility:hidden" width="200px"/>
                </div>
              </td>
            </tr>

            </tbody>
          </table>
        </div>
        <div class="buttons">
          <span class="button"><input class="save" type="submit" value="发起话题" /></span>
        </div>
      </g:uploadForm>
    </div>


  </body>
</html>
